package com.ls.pattern.behavior.command;

import com.ls.pattern.behavior.command.light.LightOffCommand;
import com.ls.pattern.behavior.command.light.LightOnCommand;
import com.ls.pattern.behavior.command.light.LightReceiver;
import com.ls.pattern.behavior.command.tv.TVOffCommand;
import com.ls.pattern.behavior.command.tv.TVOnCommand;
import com.ls.pattern.behavior.command.tv.TVReceiver;

public class Main {
    public static void main(String[] args) {
        //创建电灯的对象(接收者)
        LightReceiver lightReceiver = new LightReceiver();
        //创建电灯相关的开关命令
        LightOnCommand onCommand = new LightOnCommand(lightReceiver);
        LightOffCommand offCommand = new LightOffCommand(lightReceiver);

        RemoteController controller = new RemoteController();
        //给遥控器设置命令 no = 0 是电灯的开合关的操作
        controller.setCommand(0, onCommand, offCommand);

        controller.onButtonWasPushed(0);
        controller.offButtonWasPushed(0);
        controller.undoButtonWasPushed(0);

        //创建电灯的对象(接收者)
        TVReceiver tvReceiver = new TVReceiver();
        //创建电灯相关的开关命令
        TVOnCommand tvOnCommand = new TVOnCommand(tvReceiver);
        TVOffCommand tvOffCommand = new TVOffCommand(tvReceiver);


        //给遥控器设置命令 no = 0 是电视的开合关的操作
        controller.setCommand(1, tvOnCommand, tvOffCommand);

        controller.onButtonWasPushed(1);
        controller.offButtonWasPushed(1);
        controller.undoButtonWasPushed(1);
    }

}
